﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Configuration;
using System.Net.Mail;
using System.IO;

namespace VISS.Web.Frontend {

    public class MailUtils {

        public static bool SendMail(string subject, string body, string fromAddress, string senderName, string toMail, bool isHtml, bool isSSL) {
            try {
                using (MailMessage mail = new MailMessage()) {
                    mail.From = new MailAddress(fromAddress, senderName);
                    mail.To.Add(toMail);
                    mail.Subject = subject;
                    mail.Body = body;
                    mail.IsBodyHtml = isHtml;
                    SmtpClient client = new SmtpClient();
                    client.EnableSsl = isSSL;
                    client.Send(mail);
                }
            }
            catch (SmtpException ex) {
                return false;
            }
            return true;
        }
    }
}
